package com.scalar.chiptrack.operations.bins.forms;

import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionMapping;

import com.scalar.chiptrack.ChipTrackActionForm;
import com.scalar.chiptrack.operations.process.BinSetup;

public class AssemblyBinForm extends ChipTrackActionForm
{
    int baseProductId = -1;
    int assemblyProccessStepId = -1;
    ArrayList binInformationList = new ArrayList();
    ArrayList binInformationListCopy = new ArrayList();

    public AssemblyBinForm()
    {
        baseProductId = -1;
        assemblyProccessStepId = -1;
    }

    public int getBaseProductId()
    {
        return baseProductId;
    }

    public void setBaseProductId(int baseProductProccessStepId)
    {
        this.baseProductId = baseProductProccessStepId;
    }

    public int getAssemblyProccessStepId()
    {
        return assemblyProccessStepId;
    }

    public void setAssemblyProccessStepId(int assemblyProccessStepId)
    {
        this.assemblyProccessStepId = assemblyProccessStepId;
    }

    public ArrayList getBinInformationList()
    {
        return binInformationList;
    }

    public void setBinInformationList(ArrayList binInformationList)
    {
        this.binInformationList = binInformationList;
    }

    public ArrayList getBinInformationListCopy() {
        return binInformationListCopy;
    }

    public void setBinInformationListCopy(ArrayList binInformationListCopy) {
        this.binInformationListCopy = binInformationListCopy;
    }

    public String toString()
    {
        StringBuffer binDetails = new StringBuffer();
        BinSetup binSetup = null;

        binDetails.append( " Assm_ProcessStep_ID =  " +  assemblyProccessStepId + "\n");

        for( int i = 0 ; i < binInformationList.size(); i++ )
        {
           binSetup = ( BinSetup ) binInformationList.get( i );
           binDetails.append( " Bin_Number =  " +  binSetup.getBinNo() + "\n");
           binDetails.append( " Bin_Type =  " +  binSetup.getBinType() + "\n");
           binDetails.append( " Bin_Selected =  " +  binSetup.isSelectedBin() + "\n");
        }
        return binDetails.toString();
    }

    public void reset( ActionMapping  mapping, HttpServletRequest request )
    {
       baseProductId = -1;
       assemblyProccessStepId = -1;
       BinSetup binSetup = null;
       for( int i = 0 ; i < binInformationList.size(); i++ )
       {
           binSetup = ( BinSetup ) binInformationList.get( i );
           binSetup.setSelectedBin( false );
       }
    }
}
